Skip to content

Conversation

@ahouseholder
Copy link
Contributor

This PR takes advantage of our switch to pydantic data classes in #674 to add a field validator on the _Versioned mixin class that enforces valid semver strings in theversion attribute.

Copilot summary

This pull request includes updates to the src/ssvc/_mixins.py file to improve version validation by adding a new dependency and a validation method.

Validation improvements:

  • src/ssvc/_mixins.py: Added semver library import to handle version parsing and validation.
  • src/ssvc/_mixins.py: Introduced a validate_version method in the _Versioned class using field_validator to ensure the version field is a valid version number. This method parses the version string and raises a ValueError if it is not valid.

@ahouseholder ahouseholder added enhancement New feature or request python Pull requests that update Python code labels Feb 19, 2025
@ahouseholder ahouseholder added this to the 2025-03 milestone Feb 19, 2025
@ahouseholder ahouseholder self-assigned this Feb 19, 2025
@ahouseholder ahouseholder linked an issue Feb 19, 2025 that may be closed by this pull request
@ahouseholder ahouseholder merged commit 9c3f608 into main Feb 19, 2025
4 checks passed
@ahouseholder ahouseholder deleted the 347-add-regex-check-for-semver-formatting-in-versioned-python-objects branch February 19, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add regex check for semver formatting in versioned python objects

3 participants